package ase.eleitweg.server;

import ase.eleitweg.common.*;

import java.rmi.*;
import java.util.*;
import com.google.inject.*;

/**
 * @author stefan
 *
 */
@ImplementedBy(UserController.class)
public interface UserManager extends Remote {
	
	/**
	 * Retrieve all users from the DB
	 * @return
	 * @throws RemoteException
	 */
	public List<User> getUsers() throws RemoteException;
	
	/**
	 * Removes User u from DB
	 * @param u The ID of the of the object must be set!
	 * @throws RemoteException
	 */
	public void deleteUser(User u) throws RemoteException;
	
	/**
	 * Adds a new user to the DB
	 * @param u A new User, the ID should be 0 (will be later assigned by DB)
	 * @return The new ID which was assigned by DB
	 * @throws RemoteException
	 */
	public int addUser(User u) throws RemoteException;
	
	/**
	 * Updates a User which is already stored in the DB
	 * @param u Updates all Data except the ID which has already to be set (and !=0)
	 * @throws RemoteException
	 */
	public void updateUser(User u) throws RemoteException;
	
	/**
	 * Returns all groups including theri groups
	 * @return
	 * @throws RemoteException
	 */
	public List<Group> getGroups() throws RemoteException;
	
	public Group getGroupById(int id) throws RemoteException;
	
	/**
	 * Removes group from DB, it's users stay unchanged
	 * @param g
	 * @throws RemoteException
	 */
	public void deleteGroup(Group g) throws RemoteException;
	
	/**
	 * Adds a new group to DB 
	 * @param g
	 * @return
	 * @throws RemoteException
	 */
	public int addGroup(Group g) throws RemoteException;
	
	/**
	 * Updates data of a group which is already in the DB. Assignments User-Group are not affected by this method.
	 * @param g
	 * @throws RemoteException
	 */
	public void updateGroup(Group g) throws RemoteException;
	
	/**
	 * Returns a user from the DB with given ID if such user exists, otherwise null.
	 * @param id
	 * @return
	 * @throws RemoteException
	 */
	public User getUserById(int id) throws RemoteException;
	
	/**
	 * Adds the assignment of user u to group g to the DB. The ID of user and group have to be !=0
	 * @param u
	 * @param g
	 * @throws RemoteException
	 */
	public void addUserToGroup(User u, Group g) throws RemoteException;
	
	/**
	 * Remove the assignment of user u to group g to the DB. The ID of user and group have to be !=0
	 * @param u
	 * @param g
	 * @throws RemoteException
	 */
	public void removeUserFromGroup(User u, Group g) throws RemoteException;
}
